/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package coalescent.is.nb.jobs;

import cef.command.Command;
import cef.pui.EventConstructionException;
import cef.pui.EventImpl;
import coalescent.is.cef.command.RunSamplers_Multi_Cmd;
import coalescent.is.cef.command.listener.RunSamplers_Multi_PW;
import coalescent.is.cef.pui.RunSamplers_Multi_EvtImpl;
import coalescent.nb.jobs.properties.Propertys_Coa;
import commons.nb.jobs.Job;
import commons.nb.jobs.properties.BuilderProperty;
import commons.nb.jobs.properties.ComboProperty;
import commons.nb.jobs.properties.ComboPropertyImpl;
import commons.nb.jobs.properties.PropertySets;

import static coalescent.nb.jobs.properties.ComboPropertys_Coa.K69List;

/**
 * @since
 * @version
 * @author Susanta Tewari
 * @history Created on 4/4/13.
 */
public class MLE_K69_IS_Job extends Job<RunSamplers_Multi_EvtImpl> {

    /** data builder property for K69Data */
    private final BuilderProperty k69data_bp;

    public MLE_K69_IS_Job() {

        setName("is-mle-k69");
        setDisplayName("<b>MLE-Infinite-Sites (K69)</b>");
        setShortDescription("Computes MLE for Infinite-Sites (K69) Model");

        //J- Data
        final String data_pfx = "coalescent.builder.GeneTree";
        k69data_bp = Propertys_Coa.of_Builder_K69Data(data_pfx);
        addComboProperty(k69data_bp);

        // Data-theta-Range
        final String range_pfx = "coalescent.builder.K69List.theta";
        final ComboProperty theta_range_prop = K69List(range_pfx);
        theta_range_prop.setPropertySet(PropertySets.DATA);
        addComboProperty(theta_range_prop); //J+



        // samplers, trackers & markers
        final String prefix = "coalescent.is.MultiISamplers";

        addComboProperty(Prob_K69_IS_Job.MyProps.samplers(prefix));    // samplers w/ itr strategies
        addJobProperty(Props_IS.TRACKERS.allMulti());    // trackers
        addComboProperty(new ComboPropertyImpl(Props_IS.color(prefix, false)));    // markers (color)


        // output listeners
        addCommandOutputListener(new RunSamplers_Multi_PW());
    }

    @Override
    public boolean isCancellable() {
        return RunSamplers_Multi_Cmd.isCancellable();
    }

    @Override
    public Class<? extends EventImpl> getEventImplType() {
        return RunSamplers_Multi_EvtImpl.class;
    }

    @Override
    protected RunSamplers_Multi_EvtImpl createEvent() throws EventConstructionException {
        return new RunSamplers_Multi_EvtImpl(getProperties());
    }

    @Override
    protected Command createCommand(final RunSamplers_Multi_EvtImpl event) {
        return new RunSamplers_Multi_Cmd(event);
    }
}
